trigger
	event
	endevent

	action
		unit vel = null
		set udg_TempLocation = GetRandomLocInRect(udg_CreateDinoRects[GetRandomInt(0 , 3)])
		set vel = CreateUnit(Player(11) , 'o001', GetLocationX(udg_TempLocation) , GetLocationY(udg_TempLocation) , 0.0)
		call RemoveLocation(udg_TempLocation)
		set udg_TempLocation = GetRandomLocInRect(GetPlayableMapRect())
		call IssuePointOrderLoc(vel , "attack" , udg_TempLocation)
		call RemoveLocation(udg_TempLocation)
		call CreateVelControler(vel)
		call TriggerExecute(gg_trg_CreateDinoCommon)
	endaction
endtrigger

function CreateVelControler takes unit vel returns nothing
	timer controlTimer = CreateTimer()
	set vel.dinoControlTimer = controlTimer
	//--
	timerstart controlTimer interval GetRandomReal(10.0 , 20.0) , REPEAT
		integer whichTarget = 0
		location targetLocation = null
		location castLocation = null
		location velLocation = GetUnitLoc(vel)
		boolean foundTarget = false
		unit targetUnit = null
		real distance = 0.0
		//--PolarProjectionBJ
		set whichTarget = 0
		loop
		exitwhen whichTarget > udg_TargetPriorityListSize
			set targetUnit = udg_TargetPriorityList[whichTarget]
			set targetLocation = GetUnitLoc(targetUnit)
			set castLocation = PolarProjectionBJ(targetLocation , 200.0 , GetUnitFacing(targetUnit))
			set distance = DistanceBetweenPoints(castLocation , velLocation)
			if GetUnitState(targetUnit , UNIT_STATE_LIFE) > 0.0 and distance < 800.0 and distance > 400.0 then
				call IssueTargetOrder(vel , "attack" , targetUnit)
				call IssuePointOrderLoc(vel , "healingward" , castLocation)
				set foundTarget = true
			endif
			call RemoveLocation(targetLocation)
			call RemoveLocation(castLocation)
		exitwhen foundTarget
		set whichTarget = whichTarget + 1
		endloop
		call RemoveLocation(velLocation)
	endtimerstart
	call SaveTimerHandle(udg_UnitDataHashtable , unitId , udg_DINO_CONTROL_TIMER , controlTimer)//死亡時刪除此timer
endfunction